package content
{
	import _Pan3D.base.Camera3D;
	import _Pan3D.core.MathCore;
	
	import _me.Scene_data;
	
	import com.adobe.utils.PerspectiveMatrix3D;
	
	import flash.display.BitmapData;
	import flash.display3D.Context3D;
	import flash.display3D.Context3DBlendFactor;
	import flash.display3D.Context3DCompareMode;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Context3DTriangleFace;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	

	public class SceneLevel
	{
		public var _heorLevle:HeroLevle;

		public var _projMatrix:PerspectiveMatrix3D;
		public var _keyControl:NewKeyControl=new NewKeyControl

		public function SceneLevel()
		{
		}

		public function initData():void
		{
			makeScene();
			_keyControl.init(Scene_data.stage);
			initCam();
		}
		
		private function initCam():void{
			var came:Camera3D = Scene_data.cam3D;
			came.distance = 90;
			Scene_data.focus3D.angle_x = -45;
		}


		public function makeScene():void
		{
			_heorLevle=new HeroLevle();
		}

		public function upData():void
		{
			if (!Scene_data.ready)
				return;

			//Scene_data.groundLightText=Scene_data.sceneLightText
			var context3D:Context3D=Scene_data.context3D;

			MathCore._catch_cam(Scene_data.cam3D, Scene_data.focus3D);
			context3D.clear(0.5, 0.5, 0.5, 1);
			_projMatrix=new PerspectiveMatrix3D();
			_projMatrix.perspectiveFieldOfViewLH(1, 1, 0.1, 9000);
			context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, _projMatrix, true);
			context3D.setBlendFactors(Context3DBlendFactor.ONE, Context3DBlendFactor.ZERO);
			context3D.setDepthTest(true, Context3DCompareMode.LESS);
//			_groundView.upData();
//			context3D.setDepthTest(true, Context3DCompareMode.ALWAYS);
//			_groundUpLevel.upData();
//			context3D.setDepthTest(true, Context3DCompareMode.LESS);
//			_buildView.upData();
//			_treeLevel.upData();
			_heorLevle.upData();
//			_glassLevel.upData();
//			_npcLevel.upData();
			//_luoYeLevel.upData();
			

			context3D.present();



		}

		

		public function stageResize():void
		{
			Scene_data.cam3D.fovw=Scene_data.stageWidth;
			Scene_data.cam3D.fovh=Scene_data.stageHeight;
			var context3D:Context3D=Scene_data.context3D;
			context3D.configureBackBuffer(Scene_data.stageWidth, Scene_data.stageHeight, 0, true);
		}
	}
}
